﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AutoTLBB
{
	public partial class AlertConfigControl : UserControl
	{
		private UserDefine m_dataContext;
		public AlertConfigControl()
		{
			InitializeComponent();
		}
		public void SetDataContext(UserDefine model)
		{
			m_dataContext = model;
			if (m_dataContext == null) { return; }
			m_chkIsSelected.Checked = m_dataContext.IsSelected;
			m_chkIsSelected.Text = m_dataContext.Text;
			m_txtMinValue.Text = m_dataContext.Value.ToString();
		}

		private void m_chkIsSelected_CheckedChanged(object sender, EventArgs e)
		{
			if (m_dataContext == null) { return; }
			m_dataContext.IsSelected = m_chkIsSelected.Checked;
		}

		private void m_txtMinValue_TextChanged(object sender, EventArgs e)
		{
			if(m_dataContext== null){return;}
			m_dataContext.Value = m_txtMinValue.Text.Length ==0? 0: Int32.Parse(m_txtMinValue.Text);
		}
	}
}
